<script th:inline="javascript">
    /*<![CDATA[*/

    function del(event, element) {
        event.preventDefault();

        var _goodsId = $(element).attr("href").split("_")[0];
        var _creditPromotionId = $(element).attr("href").split("_")[1];
        var _page = $(element).attr("href").split("_")[2];
        var _viewState = $(element).attr("href").split("_")[3];

        var data = {goodsId: _goodsId, creditPromotionId: _creditPromotionId, page: _page, viewState: _viewState};

        $.ajax({
            url: "/promotion/creditpromotiongoods/ajaxDelete",
            cache: false,
            type: "post",
            data: data,
            success: function (result) {
                $("#div_goods_grid").html(result);
            }
        });
    }

    /*]]>*/
</script>

<table layout:fragment="goods_table" class="table table-striped table-bordered  table-advance table-hover" id="goods_grid" onload="myfunction()">
	<thead>
		<tr>
            <th>编号</th>
			<th>商品名称</th>
            <th>货号</th>
            <th>价格</th>
			<th th:if="${creditPromotion.creditType.description} == '倍数'">倍数</th>
			<th th:if="${creditPromotion.creditType.description} == '积分'">积分值</th>
            <th>操作</th>
		</tr>
	</thead>	
	<tbody>
		<tr class="odd gradeX" th:each="data : ${goodsPage}">
            <td th:text="${data.id}">

			</td>
			<td th:text="${data.name}">
				 
			</td>
            <td th:text="${data.goodsSN}">

			</td>
            <td th:text="${data.shopPrice}">

			</td>
			<td th:if="${creditPromotion.creditType.description} == '倍数' and ${data.creditPromotionGoods}" th:text="${data.creditPromotionGoods.multiple}">
			</td>
            <td th:if="${creditPromotion.creditType.description} == '倍数' and not ${data.creditPromotionGoods}" >
				 <input type="text" style="width:160px;float:left;margin-right:10px;" placeholder="倍数"  th:id="@{'multiple'+${data.id}}" class="form-control" />
			</td>
			<td th:if="${creditPromotion.creditType.description} == '积分' and ${data.creditPromotionGoods}" th:text="${data.creditPromotionGoods.credit}">
			</td>
            <td th:if="${creditPromotion.creditType.description} == '积分' and not ${data.creditPromotionGoods}">
				<input type="text" style="width:160px;float:left;margin-right:10px;" placeholder="积分值"  th:id="@{'credit'+${data.id}}" class="form-control" />
			</td>
            <td th:unless="${data.creditPromotionGoods}">
                <a href="#" th:href="${data.id}+'_'+${creditPromotionId}+'_'+${goodsPage.number}" th:attr="id=${'link_addgoods_'+dataStat.index},name=${'link_addgoods_'+dataStat.index}" class="btn default btn-xs purple" style="margin-top:7px;" onclick="add(event,this);"><i class="fa fa-plus"></i>添加</a>
            </td>
             <td th:if="${data.creditPromotionGoods}">
                <a href="#" th:href="${data.id}+'_'+${creditPromotionId}+'_'+${goodsPage.number}+'_'+${viewState}" th:attr="id=${'link_deletegoods_'+dataStat.index},name=${'link_deletegoods_'+dataStat.index}" class="btn default btn-xs purple" style="margin-top:7px;" onclick="del(event,this);"><i class="fa fa-minus"></i>删除</a>
            </td>
		</tr>
 	</tbody>
</table>
<div th:include="page_footer" th:with="viewState=${viewState},url=${'/promotion/creditpromotiongoods/list/'+creditPromotionId+'/'},pageContext=${goodsPage}"></div>